'''
Created on 06/03/2013

@author: mrodri20
'''
import os
from os import listdir
from os.path import isfile, join

def process_filename(filename):
    """
    Filename that process
    """
    int_idx = filename.find('.A')
    
    new_subsrt = filename[int_idx+2:]
    
    int_idx = new_subsrt.find('.')
    
    yearday_subsrt = new_subsrt[:int_idx]
    hourly_sub = new_subsrt[int_idx+1:int_idx+5]
    
    print "prefix: %s" % new_subsrt 

def process_files():
    """
    method to process all the files in a directory
    - it reads the file and calls the module for grib file processing
    - then it renames the output file according to the date
    - 
    """

    mypath =  os.path.abspath("." )   
    
    onlyfiles = [ f for f in listdir(mypath) if isfile(join(mypath,f)) ]
    
    process_filename('GLDAS_NOAH025SUBP_3H.A2012058.0300.001.2013059204729.grb')
    
#    for p in onlyfiles:
#        print "file:" + p;

if __name__ == '__main__':
    process_files()